

from app.lib.WeChatAlert import WeChatAlert, WeChatAlertException
from funboost import (
    boost,
    BrokerEnum,
    BoosterParams,
)

"""
如果发布者要获取消费结果一定要设置is_using_rpc_mode=True
"""


@boost(
    BoosterParams(
        queue_name="wechat_alert_queue",
        broker_kind=BrokerEnum.RABBITMQ_AMQPSTORM,
        concurrent_num=1,
        is_using_rpc_mode=True,
        retry_interval=10,
        max_retry_times=10,
        is_show_message_get_from_broker=True,
        qps=1,
    )
)
def alert_wechat(wx_name=None, room_name=None, alert_message="这是一个测试告警"):
    if wx_name and room_name:
        raise WeChatAlertException("wx_name和room_name不能同时存在")

    wechat_alert = WeChatAlert()
    return wechat_alert.send_message(wx_name=wx_name, room_name=room_name, message=f"{alert_message}")
